package com.love.marriage.userCommissionWithdrawalHistory.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.love.marriage.common.interfaces.avoid.AvoidRepeatableCommit;
import com.love.marriage.common.validator.Insert;
import com.love.marriage.common.validator.Update;
import com.love.marriage.common.vo.Result;
import com.love.marriage.common.vo.ResultBoolean;
import com.love.marriage.userCommissionWithdrawalHistory.service.UserCommissionWithdrawalHistoryService;
import com.love.marriage.userCommissionWithdrawalHistory.vo.ResultUserCommissionWithdrawalHistoryVo;
import com.love.marriage.userCommissionWithdrawalHistory.vo.ResultUserCommissionWithdrawalHistoryVoPage;
import com.love.marriage.userCommissionWithdrawalHistory.vo.UserCommissionWithdrawalHistoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * description:  用户提现回佣金额历史表restApi
 * author:       mybatisPlus
 * createDate:   2024-11-10 18:46:48
 * version:      1.0.0
 */
@ApiSort(105)
@Tag(name = "用户提现回佣金额历史表相关接口", description = "用户提现回佣金额历史表相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/user-commission-withdrawal-history")
public class UserCommissionWithdrawalHistoryController {

    private final UserCommissionWithdrawalHistoryService userCommissionWithdrawalHistoryService;

    @ApiOperationSupport(order = 10, author = "mybatisPlus")
    @Operation(summary = "提现列表分页", description = "提现列表分页")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultUserCommissionWithdrawalHistoryVoPage.class
                    )))
    @PostMapping(value = "/page")
    @Parameters({
            @Parameter(name = "pageNum", description = "页码", required = false),
            @Parameter(name = "pageSize", description = "每页大小", required = false)
    })
    @Tag(name = "回佣", description = "回佣相关接口")
    public Result<Page<UserCommissionWithdrawalHistoryVo>> getPage(@RequestParam(value = "pageNum", required = false) Long pageNum,
                                                                   @RequestParam(value = "pageSize", required = false) Long pageSize,
                                                                   @RequestBody(required = false) UserCommissionWithdrawalHistoryVo userCommissionWithdrawalHistoryVo) {
        return Result.success(userCommissionWithdrawalHistoryService.getPage(pageNum, pageSize, userCommissionWithdrawalHistoryVo));
    }

    @ApiOperationSupport(order = 15, author = "mybatisPlus")
    @Operation(summary = "提现列表", description = "提现列表")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultUserCommissionWithdrawalHistoryVoPage.class
                    )))
    @PostMapping(value = "/list")
    @Tag(name = "回佣", description = "回佣相关接口")
    public Result<List<UserCommissionWithdrawalHistoryVo>> getList(@RequestBody(required = false) UserCommissionWithdrawalHistoryVo userCommissionWithdrawalHistoryVo) {
        return Result.success(userCommissionWithdrawalHistoryService.getList(userCommissionWithdrawalHistoryVo));
    }

    @ApiOperationSupport(order = 20, author = "mybatisPlus")
    @Operation(summary = "获取用户提现回佣金额历史表详情", description = "获取用户提现回佣金额历史表详情")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultUserCommissionWithdrawalHistoryVo.class
                    )))
    @Parameters({
            @Parameter(name = "id", description = "id", required = true, schema = @Schema(implementation = Long.class, type = "Long", example = "1"))
    })
    @GetMapping
    public Result<UserCommissionWithdrawalHistoryVo> query(@RequestParam(value = "id") Long id) {
        return Result.success(userCommissionWithdrawalHistoryService.queryUserCommissionWithdrawalHistory(id));
    }

    @AvoidRepeatableCommit
    @ApiOperationSupport(order = 30, author = "mybatisPlus")
    @Operation(summary = "新增用户提现回佣金额历史表", description = "新增用户提现回佣金额历史表",
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    description = "查询条件",
                    required = false,
                    content = @Content(schema = @Schema(implementation = UserCommissionWithdrawalHistoryVo.class))
            ))
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(schema = @Schema(implementation = ResultUserCommissionWithdrawalHistoryVo.class)))
    @PostMapping
    public Result<UserCommissionWithdrawalHistoryVo> add(@Validated({Insert.class}) @RequestBody UserCommissionWithdrawalHistoryVo userCommissionWithdrawalHistoryVo) {
        return Result.success(userCommissionWithdrawalHistoryService.addUserCommissionWithdrawalHistory(userCommissionWithdrawalHistoryVo));
    }

    @ApiOperationSupport(order = 40, author = "mybatisPlus")
    @Operation(summary = "修改用户提现回佣金额历史表", description = "修改用户提现回佣金额历史表",
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    description = "查询条件",
                    required = false,
                    content = @Content(schema = @Schema(implementation = UserCommissionWithdrawalHistoryVo.class))
            ))
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(schema = @Schema(implementation = ResultUserCommissionWithdrawalHistoryVo.class)))
    @PutMapping
    public Result<UserCommissionWithdrawalHistoryVo> update(@Validated({Update.class}) @RequestBody UserCommissionWithdrawalHistoryVo userCommissionWithdrawalHistoryVo) {
        return Result.success(userCommissionWithdrawalHistoryService.updateUserCommissionWithdrawalHistory(userCommissionWithdrawalHistoryVo));
    }

    @ApiOperationSupport(order = 50, author = "mybatisPlus")
    @Operation(summary = "刪除用户提现回佣金额历史表", description = "刪除用户提现回佣金额历史表")
    @Parameters({
            @Parameter(name = "ids", description = "ids,用，分割", required = true, schema = @Schema(implementation = String.class, type = "String", example = "1,2"))
    })
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(schema = @Schema(implementation = ResultBoolean.class)))
    @DeleteMapping
    public Result<Boolean> delete(@RequestParam("ids") String ids) {
        return Result.success(userCommissionWithdrawalHistoryService.deleteUserCommissionWithdrawalHistory(ids));
    }
}
